<script setup>
import {ref} from "vue";
import BuildLibrary from "@/options/views/similarity-img-search/BuildLibrary.vue";
import Search from "@/options/views/similarity-img-search/Search.vue";


// 当前激活的标签
const activeTab = ref('search')
// 标签点击事件
const handleTabClick = (tab) => {
  // console.log('切换到标签:', tab.props.name)
  activeTab.value = tab.props.name
}

</script>

<template>
  <div class="app-container">
    <div class="layout-wrapper">
      <!-- 左侧标签栏 -->
      <div class="tab-sidebar">
        <el-tabs
            v-model="activeTab"
            tab-position="left"
            class="vertical-tabs"
            @tab-click="handleTabClick">
          <el-tab-pane label="搜索相似图片" name="search" lazy>
          </el-tab-pane>
          <el-tab-pane label="构建图库" name="library" lazy>
          </el-tab-pane>
        </el-tabs>
      </div>

      <!-- 右侧内容区域 -->
      <div class="content-main">
        <!-- 搜索相似图片内容 -->
        <div v-show="activeTab === 'search'" class="tab-content">
          <Search />
        </div>

        <!-- 构建图片库内容 -->
        <div v-show="activeTab === 'library'" class="tab-content">
          <BuildLibrary />
        </div>
      </div>
    </div>
  </div>

</template>

<style scoped>
.app-container {
  width: 100%;
  /*height: 100vh;*/
  background-color: white;
}

.layout-wrapper {
  display: flex;
  height: 100%;
}

.tab-sidebar {
  width: 180px;
  background: white;
}

.content-main {
  flex: 1;
  padding: 0;
  /*overflow-y: auto;*/
}

.tab-content {
  height: 100%;
  padding: 24px;
  animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateX(10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* 全局样式覆盖 */
.vertical-tabs .el-tabs__header {
  margin-right: 0;
  border-right: none;
}

.vertical-tabs .el-tabs__item {
  width: 100%;
  text-align: left;
  padding: 16px 20px;
  border-bottom: 1px solid #f0f0f0;
}

.vertical-tabs .el-tabs__item:last-child {
  border-bottom: none;
}

.vertical-tabs .el-tabs__content {
  padding: 0;
}
</style>